<?php

	$order=" id desc";
	$url="";
	if(isset($_GET['ext'])){
		
		
		
		switch($_GET['ext']){
			case 'views':
			case 'likes':
			case 'comments':
			$order= $_GET['ext']." ".$_GET['sort'];
			break;
			case "date":
			$order= "id ".$_GET['sort'];
		}
	$url="";
	
	
	}


	if(!isset($_GET['page']) || $_GET['page']==1 || $_GET['page']% LOAD_TIME ==0){
	$cache=new Cache;
	$sql ="select * from album  order by ".$order;
	$sql2="select id from album";

	$pager = new Pagination($sql,3,4,$url,5,'album');
	$pager->setDebug(false);
	$data[info] = $pager->paginate($cache,$sql2);
	$data[nav]	= $pager->renderFullNav();
	$data['page']=$pager->get_num_page();
	
	if($data['page']<$_GET['page']){
		$data[info]='';
	}
	
	$title= 'ALBUM';
	if(isset($_GET['ext'])){
		$title.=" - ".$_GET['ext']." ".$_GET['sort'];
	
	}
	
	
	if(isset($_GET['page'])){
	$title.=" -  Trang ".($_GET['page']);
	}

	$data1[title]=$title;


		loadview('template/header',$data1);
		if($_SESSION['mobile']!=0){
			loadview("news/list_album",$data);
		}else{
		loadview("news/list_album_grid",$data);
		}
		//loadview('template/right');
	}else{
		exit();
	}


	

?>